Xbasic

EVAL_VALID Function

Syntax

Result_Flag as L = EVAL_VALID(Expression as C [,eval_context as C [,session as N]])

Arguments

ExpressionCharacter

A quoted Xbasic statement.

eval_contextCharacter

The context in which the expression should be evaluated. This can be a list of tables in a CR-LF delimited list. It can also be the name of an open form (suffixed by ".this"), which would evaluate the expression in the context of the form.

sessionNumeric

Session context.

Returns

Result_FlagLogical

Returns .t. if Expression is valid, otherwise .f.

Description

Return True if the expression can be parsed (expression is properly formed), session context is optional.

Discussion

EVAL_VALID() evaluates Expression and returns .T. (TRUE), if Expression is valid (can be interpreted as Xbasic code), or .F. (FALSE) if the Expression is invalid. This function is useful when the expression to be evaluated is itself constructed by another expression.

Example

dim varA as N
dim varB as N
varA = 1
varB = 2

dim theExpression as C
theExpression = "varA + varB"

? eval_valid("1 + 2")
= .T.

? eval_valid("varA + varB")
= .T.

? eval_valid(theExpression)
= .T.

? eval_valid("date() ")
= .T.

' daaate() is not a function
? eval_valid("daaate() ")
= .F.

For more examples on how the Context parameter is used, see EVAL().

See Also